package com.sofwin.controller;

import com.sofwin.ResponseEntity;
import com.sofwin.pojo.Node;
import com.sofwin.pojo.SysDept;
import com.sofwin.service.DeptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * @packageName: com.sofwin.controller
 * @user: andyliu
 * @date: 2022/12/31 11:20
 * @email 115176513@qq.com
 * @description: TODO
 */

@Controller
@RequestMapping("dept")
public class DeptController {
    @Autowired
    private DeptService deptService;

    @GetMapping("allDept")
    @ResponseBody
    public ResponseEntity allDept(){
        List<SysDept> depts = deptService.queryAll();
        return ResponseEntity.success(depts);
    }
    @GetMapping("/tree/data")
    @ResponseBody
    public ResponseEntity treeData(){
        List<Node> data = deptService.queryTreeData();
        return ResponseEntity.success(data);
    }
}
